package com.ihemou.system.service.impl;

import com.ihemou.system.domain.SysUserSocialApp;
import com.ihemou.system.mapper.SysUserSocialAppMapper;
import com.ihemou.system.service.ISysUserSocialAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * All rights Reserved, Designed By saperliu
 * Copyright:    Copyright(C) 2021-2021
 * 应用所属用户Service业务层处理
 *
 * @author saperliu
 * @date 2021年09月02日
 */
@Service
public class SysUserSocialAppServiceImpl implements ISysUserSocialAppService {
    @Autowired
    private SysUserSocialAppMapper sysUserSocialAppMapper;


    /**
     * 根据条件分页查询应用所属用户数据
     *
     * @param sysUserSocialApp 过滤条件
     * @return 应用所属用户数据集合信息
     */
    @Transactional(readOnly = true)
    @Override
    public List<SysUserSocialApp> findSysUserSocialAppByCondition(SysUserSocialApp sysUserSocialApp) {

        return sysUserSocialAppMapper.findSysUserSocialAppByCondition(sysUserSocialApp);
    }


    /**
     * 查询应用所属用户
     *
     * @param id 应用所属用户ID
     * @return 应用所属用户
     */
    @Transactional(readOnly = true)
    @Override
    public SysUserSocialApp selectSysUserSocialAppById(String id) {
        return sysUserSocialAppMapper.selectById(id);
    }


    /**
     * 新增应用所属用户
     *
     * @param sysUserSocialApp 应用所属用户
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int insertSysUserSocialApp(SysUserSocialApp sysUserSocialApp) {
        return sysUserSocialAppMapper.insert(sysUserSocialApp);
    }

    /**
     * 修改应用所属用户
     *
     * @param sysUserSocialApp 应用所属用户
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int updateSysUserSocialApp(SysUserSocialApp sysUserSocialApp) {
        return sysUserSocialAppMapper.updateById(sysUserSocialApp);
    }

    /**
     * 批量删除应用所属用户
     *
     * @param ids 需要删除的应用所属用户ID
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int deleteSysUserSocialAppByIds(String[] ids) {

        return sysUserSocialAppMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除应用所属用户信息
     *
     * @param id 应用所属用户ID
     * @return 结果
     */
    @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    @Override
    public int deleteSysUserSocialAppById(String id) {
        return sysUserSocialAppMapper.deleteById(id);
    }

}
